package grammarbot

import twitter4j.Twitter
import twitter4j.Status

class TweetHandler {
  TweetChecker tweetChecker
  Twitter twitter
  String responseToCorrect = null
  boolean debug = false

  void handleStatus(Status status) {
    if(status.user.lang != "en") return 

    def response = tweetChecker.check status
    if(!response && responseToCorrect) {
      response = "@" + status.user.screenName + responseToCorrect
    }

    if(response) {
      println "----------------------------------------------------"
      println "Responding to @${status.user.screenName} - ${status.text}"
      println response
      if(!debug) {
        twitter.updateStatus response, status.id
      }
    }

  }

}